import { PCTask } from '../types'
import { useGetOps } from './useGetOps'
import { usePower } from './usePower'
import { useTargetCheck } from './useTargetCheck'

/**
 * 简单使用技能
 */
export const useEasyOp = (room: MyRoom, task: PCTask, ops = 100) => {
    const { targetId, pc: pcName } = task

    const pc = Game.powerCreeps[pcName]
    if (!pc || !pc.room) {
        task.done = true
        return
    }

    if (pc.store['ops'] < ops) {
        useGetOps(room, pc)
        return
    }

    const target = Game.getObjectById(targetId) as Structure | Source | Mineral
    if (!useTargetCheck(task, target)) return

    usePower(pc, task, target)
}
